import yaml
from base_tools.my_looger import logger

def my_read_yaml(file, key_word=None):
    logger.info("读取测试数据，文件地址为：{}，关键字为：{}".format(file, key_word))
    with open(file, encoding="utf-8") as f:
        values = yaml.safe_load(f)
    if key_word:
        new_values = []
        for value in values:
            if value.get("key_word") == key_word:
                new_values.append(value)
        return new_values
    else:
        return values